var express = require('express');
var router = express.Router();

function  checklogin(req,res,next) {
    if(req.session.user){
        res.locals.data = {};
        res.locals.data.user  = req.session.user;
        res.locals.data.userString = JSON.stringify(req.session.user);
        next();

    }else{
        res.redirect("/signin");
    }
}


router.get('/',checklogin, function(req, res, next) {
    res.render('index');


});
//机器人聊天
router.get('/robot',checklogin, function(req, res, next) {

        res.render("robot");

});
//大厅聊天
router.get('/hall',checklogin, function(req, res, next) {
    res.render("hall");
});

//登录
router.get('/signin', function(req, res, next) {
  res.render('login', {  });
});

//注册
router.get('/signup', function(req, res, next) {
  res.render('signup', {  });
});

module.exports = router;
